package com.example.smartlearning.controller;

import com.example.smartlearning.service.impl.GuanZhuServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/Smart/GuanZhu/")
public class GuanZhuController {

    @Resource
    GuanZhuServiceImpl guanZhuService;

    /**
     * 获取所有的关注列表
     *
     * @param id id
     * @return 返回
     */
    @GetMapping("getGuanZhu")
    public String getCollection(@RequestParam("id") int id) {
        return guanZhuService.selectAllById(id);
    }

    /**
     * 新增关注接口
     *
     * @param userId 登录者id
     * @param id     被关注id
     * @return 返回
     */
    @PostMapping("addNew")
    public String addNew(@RequestParam("userId") int userId, @RequestParam("id") int id) {
        return guanZhuService.addNew(userId, id);
    }

    /**
     * 取消关注接口
     *
     * @param userId 登录者id
     * @param id     id
     * @return 返回
     */
    @PostMapping("cancelById")
    public String cancelById(@RequestParam("userId") int userId, @RequestParam("id") int id) {
        return guanZhuService.cancelById(userId, id);
    }


}
